
<template>
    <el-dialog :title="dataRow.csatState == 1 ? '评价详情' : '评价'" :visible.sync="rateOpen" width="30%" append-to-body
        :before-close="closeDelDialog">
        <el-form :model="form">
            <el-form-item label="满意度：" style="display: flex; flex-direction: row;align-items: center;">
                <el-rate v-model="form.csat" show-text :max="3" :texts="['一般', '满意', '十分满意']">
                </el-rate>
            </el-form-item>
            <el-form-item label="备注：" label-width="60px">
                <el-input type="textarea" placeholder="请输入备注" v-model="form.csatOpinion" maxlength="200" show-word-limit
                    style="height:100px;">
                </el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" style="display: flex;justify-content: center;">
        <el-button type="primary" @click="submitFormCh" v-if="dataRow.csatState!=1">确 定</el-button>
        <el-button @click="closeDelDialog">取 消</el-button>
        </div>
    </el-dialog>
</template>
<script>
import { editCast } from "@/api/archive/archiveBorrow/archiveBorrow";
export default {
    props: ['rateOpen', 'dataRow'],
    watch: {
        dataRow: {
            handler(valNew) {
                console.log(valNew, "sdklfjsdklj")
                this.form["borrowId"] = valNew.borrowId;
                if (valNew.csatState == 1) { //已评价 ，就是查看详情
                    this.form['csat'] = valNew.csat;
                    this.form['csatOpinion'] = valNew.csatOpinion;
                    this.form['csatState'] = valNew.csatState;
                }
            },
            immediate: true
        }
    },
    data() {
        return {
            form: {
                csat: 0,
                csatOpinion: undefined,
                csatState: 1 //评价状态是否已评价  0未评价   1 已评价
            }
        }
    },
    methods: {
        closeDelDialog() {
            this.$emit("closeDelDialogRate");
        },
        submitFormCh() {
            var that = this;
            if (this.form.csat == 0) {
                this.$modal.msgWarning("请选择满意度");
                return false
            }
            this.$modal.loading("加载中...")
            editCast(this.form).then(res => {
                if (res.code == "200") {
                    that.$modal.msgSuccess("操作成功")
                    that.$modal.closeLoading();
                    this.$emit("submitFormRate")
                }
            }).catch(res => {
                that.$modal.closeLoading();
                this.$emit("submitFormRate")
            })
        },
    },
}
</script>
<style lang="scss" scoped>
::v-deep .el-textarea__inner {
    height: 100% !important;
    // border: 0 !important;
}
</style>